<html>
<head>
<title>JSON4Lua and JSONRPC4Lua</title>
<style type="text/css">
body {
  font-family: Arial, Helvetica, Geneva;
  font-size: 10pt;
}

.copyright {
  color: #999999;
  font-size: 8pt;
  text-align:center;
}  

.navBar {
  border-left: 1px solid lightgray;
  border-right: 1px solid lightgray;
  border-bottom: 1px solid lightgray;
  margin-top:5px;
  margin-bottom: 5px;
}
.navBar h1 {
  background-image: url('pics/lunartone.gif');
  background-color: #e0c088;
  color: white;
  font-size: 9pt;
  margin: 0px;
  padding: 4px;
}

.navBar .navItem a {
  color: #999999;
  font-size: 8pt;
  padding: 2px 2px 2px 10px;
  text-decoration:none;
}

.navBar .navItem a:hover {
  color: #ff9900;
  text-decoration: underline;
}

.titleBar {
  border-bottom: 2px dotted gray;
  font-size: 20pt;
  font-weight: bold;
  margin-bottom: 15px;
  width: 100%;
}

.workArea {
  border: 1px none lightgray;
  font-family: Times New Roman;
  padding: 8px;
  padding-left: 15px;
}

.workArea a {
  font-weight: bold;
  text-decoration: none;
}

.workArea a:hover { 
  color: #ff9900;
  text-decoration: underline;
}

.workArea .downloadTable {
  border: 1px solid lightgray;
  padding: 0px;
  margin: 0px;
}

.workArea .downloadTable * th {
  background-color: #e0c088;
  background-image: url('pics/lunartone.gif');
  color: white;
}

.workArea .downloadTable * tr {
  border: 1px solid lightgray;
}

.workArea .downloadTable * td {
  vertical-align: top;
}

.workArea * dt {
  font-size: 12pt;
  margin-top: 10px;
}

.workArea * .example {
  background-color: #ffffcc;
  border: 1px dashed lightgray;
  padding: 10px;
}

.workArea h1 {
  font-size: 16pt;
  font-weight: bold;
}

.workArea h2 {
  font-size: 14pt;
  font-weight: normal;
  color: gray;
}

</style>
<body>
<table border="0">
  <tr>
    <td valign="top">
    <img src="pics/json4lua.gif"><p/>
    <!-- NAVIGATION BARS -->
    
    <div class="navBar">
    <h1>Home Page</h1>
    <div class="navItem"><a href="index.html#news">Latest News</a></div>    
    <div class="navItem"><a href="index.html#introduction">Introduction</a></div>
    <div class="navItem"><a href="index.html#licence">Licence</a></div>
    <div class="navItem"><a href="index.html#requirements">Requirements</a></div>
    <div class="navItem"><a href="index.html#download">Download</a></div>
    <div class="navItem"><a href="index.html#installation">Installation</a></div>    
    <div class="navItem"><a href="index.html#usage">Usage &amp; Reference</a></div>
    <div class="navItem"><a href="index.html#roadmap">History &amp; Roadmap</a></div>
    </div>	<!-- end of navigation bar: This Site  -->
    
    <div class="navBar">
    <h1>json.luaforge</h1>
    <div class="navItem"><a href="http://luaforge.net/projects/json/">Summary</a></div>
    <div class="navItem"><a href="http://luaforge.net/forum/?group_id=143">Forums</a></div>
    <div class="navItem"><a href="http://luaforge.net/tracker/?group_id=143">Tracker</a></div>
    <div class="navItem"><a href="http://luaforge.net/news/?group_id=143">News</a></div>
    <!--<div class="navItem"><a href="http://luaforge.net/scm/?group_id=143">CVS</a></div>-->
    <div class="navItem"><a href="http://luaforge.net/frs/?group_id=143">Files</a></div>
    </div>	<!-- end of navigation bar: json.luaforge -->
    
    <div class="navBar">
    <h1>Lua</h1>
    <div class="navItem"><a href="http://www.lua.org/">Lua</a></div>
    <div class="navItem"><a href="http://www.luaforge.net/">Lua Forge</a></div>
    <div class="navItem"><a href="http://www.keplerproject.org/cgilua/">CGI Lua</a></div>
    <div class="navItem"><a href="http://www.keplerproject.org/compat/">Lua compat-5.1</a></div>
    <div class="navItem"><a href="http://www.cs.princeton.edu/~diego/professional/luasocket/">Lua Socket 2.0</a></div>
    <div class="navItem"><a href="http://www.keplerproject.org/xavante/">Xavante</a></div>
    </div>	<!-- end of navigation bar: Lua Resources -->

    <div class="navBar">
    <h1>JSON</h1>
    <div class="navItem"><a href="http://www.json.org/">json.org</a></div>
    <div class="navItem"><a href="http://www.json-rpc.org/">json-rpc.org</a></div>
    </div>	<!-- end of navigation bar: Lua Resources -->

    </td>
    <!-- MAIN WORK AREA -->
    <td valign="top" class="workArea">
      <div class="titleBar">Patching CGILua to handle <code>text/plain</code></div>
      
      <!-- cgilua_patch.html -->
JSON RPC (both the JSONRPC4Lua implementation and the <a href="http://www.jsolait.net/">jsolait Javascript</a> implementation) send the http request with a Content-Type of <code>text/plain</code>.<p/>

CGILua 5.0 does not accept <code>text/plain</code> content, and will generate an error of 'Unsupported Media Type: text/plain'.<p/>

This is easily patched in CGILua 5.0 by making the following change to <code>cgilua/post.lua</code>, line 286:<p/>
Change:<pre>
	elseif strfind (contenttype, "text/xml") then
</pre>
to
<pre>
	elseif strfind (contenttype, "text/xml") or strfind (contenttype, "text/plain") then
</pre>
This makes CGILua handle <code>text/plain</code> as it does <code>text/xml</code>, without parsing the incoming POST data.<p/>

<b>Please note:</b> I have requested the maintainers of CGILua to make this change to CGILua, whereafter this patch will no longer be required.


    </td>
  </tr>
  <tr>
    <td colspan="2" class="copyright">&copy; 2005 Craig Mason-Jones</td>
  </tr>
</table>
</body>
</html>